package com.lingnan.tijian.controller;

import com.lingnan.tijian.domain.Orders;
import com.lingnan.tijian.domain.result.Result;
import com.lingnan.tijian.domain.vo.OrderVO;
import com.lingnan.tijian.service.IOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 无Controller
 * 
 * @author manba
 * @date 2024-12-26
 */
@RestController
@RequestMapping("/order")
@Slf4j
public class OrderController
{
    @Autowired
    private IOrderService orderService;

    @PostMapping
    public Result insertOrder(@RequestBody Orders order){
        log.info("订单数据:{}",order);
        orderService.insertOrder(order);
        return Result.success();
    }

    @GetMapping("/list")
    public Result<List<OrderVO>> selectOrderListByUserId(){
        List<OrderVO> list = orderService.selectOrderListByUserId();
        return Result.success(list);
    }

    @GetMapping("/report")
    public Result<List<OrderVO>> selectReportListByUserId(){
        List<OrderVO> list = orderService.selectReportListByUserId();
        return Result.success(list);
    }

    /**
     * 取消预约
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public Result cancelOrderByOrderId(@PathVariable Long id){
        orderService.cancelOrderByOrderId(id);
        return Result.success();
    }

}
